package com.yuncheng.spcyApi.spcy;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuncheng.spcyApi.alog.annotation.Log;
import com.yuncheng.spcyApi.alog.utils.StringEmptyUtils;
import com.yuncheng.spcyApi.bo.JcyLxKhjgBo;
import com.yuncheng.spcyApi.bo.ParamsBo;
import com.yuncheng.spcyApi.constant.common.LogConstant;
import com.yuncheng.spcyApi.constant.common.SpcyConstant;
import com.yuncheng.spcyApi.constant.jcy.JcyLxjhConstant;
import com.yuncheng.spcyApi.constant.jcy.JcydjbConstant;
import com.yuncheng.spcyApi.entity.*;
import com.yuncheng.exception.BusinessException;
import com.yuncheng.spcyApi.flow.XzswspFlowService;
import com.yuncheng.spcyApi.mapper.SpcyPxJbxxMapper;
import com.yuncheng.spcyApi.service.*;
import com.yuncheng.spcyApi.spcyService.SpcyJcyLxService;
import com.yuncheng.spcyApi.spcyService.ZdyUploadFileService;
import com.yuncheng.spcyApi.utils.DateConvert;
import com.yuncheng.spcyApi.utils.GetUuIdUtils;
import com.yuncheng.spcyApi.utils.OrderItemUtils;
import com.yuncheng.spcyApi.utils.StringPatternUtils;
import com.yuncheng.spcyApi.vo.common.HttpResultVo;
import com.yuncheng.spcyApi.vo.common.OrderItemVo;
import com.yuncheng.spcyApi.vo.common.PageVo;
import com.yuncheng.spcyApi.vo.jcy.JcyLxUserVo;
import com.yuncheng.spcyApi.vo.jcy.JcyLxqdjlVo;
import com.yuncheng.vo.HttpResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import utils.DateConversionUtils;
import utils.ExcelUtils;
import utils.LogUtils;
import utils.ObjectToMapUtils;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author hua
 */
@Api(tags = "检查员遴选计划管理")
@RestController
@RequestMapping("/api/spzx-spcy/jcylxjh")
public class JcyLxjhController {

    @Resource
    private ISpcyPxJbxxService spcyPxJbxxService;

    @Resource
    private ISpcyJcyLxqdcsService spcyJcyLxqdcsService;

    @Resource
    private ISpcyJcyLxpxlsService spcyJcyLxpxlsService;

    @Resource
    private ISpcyJcyLxjsjxpjService spcyJcyLxjsjxpjService;

    @Resource
    private ISpcyPxSjjbxxService spcyPxSjjbxxService;

    @Resource
    private SpcyPxJbxxMapper spcyPxJbxxMapper;

    @Resource
    private SpcyJcyLxService spcyJcyLxService;

    @Resource
    private ZdyUploadFileService zdyUploadFileService;

    @Resource
    private XzswspFlowService xzswspFlowService;

    @Resource
    @Lazy
    private ISpcyLogService spcyLogService;

    @Log(title = "遴选计划-分页查询")
    @ApiOperation(value = "遴选计划-分页查询")
    @GetMapping(value = "pageList")
    public HttpResult pageList(SpcyPxJbxx query, String gjz, PageVo pageVo, OrderItemVo orderItemVo){
        query.setFpxlx(JcyLxjhConstant.JCYLX_PXLX_XJCYPX);
        Page<SpcyPxJbxx> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());
        return HttpResult.ok(spcyPxJbxxMapper.selectLxjhPageList(page, query, gjz, orderItemVo));
//        return HttpResult.ok(spcyPxJbxxService.pageList(query, gjz, pageVo,orderItemVo));
    }

    @Log(title = "遴选计划-添加")
    @ApiOperation(value = "遴选计划-添加")
    @PostMapping(value = "addLxjh")
    public HttpResult addLxjh(@RequestBody SpcyPxJbxx bean){
        bean.setFpxlx(JcyLxjhConstant.JCYLX_PXLX_XJCYPX);
        SpcyPxJbxx SpcyPxJbxx = spcyPxJbxxService.addLxjh(bean);

        return HttpResultVo.HttpResultSave(SpcyPxJbxx, "添加成功");
    }

    @Log(title = "遴选计划-更新")
    @ApiOperation(value = "遴选计划-更新")
    @PostMapping(value = "updateLxjh")
    public HttpResult updateLxjh(@RequestBody HashMap<String, String> buffer) throws InvocationTargetException, IllegalAccessException {
       spcyPxJbxxService.updateLxjh(buffer);

        return HttpResult.ok("保存成功");
    }

    @Log(title = "遴选计划-提交")
    @ApiOperation(value = "遴选计划-提交")
    @PostMapping(value = "submitLxjh")
    public HttpResult submitLxjh(@RequestBody SpcyPxJbxx bean){
        if (StringEmptyUtils.isBlank(bean.getId())){
            throw new BusinessException("参数为空！");
        }
        SpcyPxJbxx queryJh = spcyPxJbxxService.getById(bean.getId());
        if (queryJh == null){
            throw new BusinessException("没有相匹配的数据！");
        }


        if (queryJh.getFjhzt().equals(JcyLxjhConstant.LX_JHZT_BMSH)){

            // 同步签到场次人数
            syncQdcsCjryNumber(queryJh.getId());
            queryJh.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_WKS);

            // 验证审批流程是否结束
//            xzswspFlowService.verifyJcyLxInBmshLcIsEnd(bean.getId());

        }else if (queryJh.getFjhzt().equals(JcyLxjhConstant.LX_JHZT_PXGL)){

            queryJh.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
            queryJh.setFpxqdzt(JcyLxjhConstant.JCYLX_PXZT_WKS);

        }
        else if (queryJh.getFjhzt().equals(JcyLxjhConstant.LX_JHZT_PXKH)){
            if (StringUtils.isBlank(queryJh.getFpxsjid())){
                throw new BusinessException("请选择培训相关的试卷！");
            }

        }
        else if (queryJh.getFjhzt().equals(JcyLxjhConstant.LX_JHZT_DRMD)){

            // 完成-自动将对应状态结束
            queryJh.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
            queryJh.setFpxqdzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
            queryJh.setFpxkszt(JcyLxjhConstant.JCYLX_PXZT_WKS);
            queryJh.setFlxwcsj(DateConversionUtils.DateToDays(new Date()));

            // 验证审批流程是否结束
//            xzswspFlowService.verifyJcyLxInQrmdLcIsEnd(bean.getId());
        }

        String lxjhZt = JcyLxjhConstant.getNextLxjhZt(queryJh.getFjhzt());
        queryJh.setFjhzt(lxjhZt);
        spcyPxJbxxService.updateById(queryJh);

        if (lxjhZt.equals(JcyLxjhConstant.LX_JHZT_JHWC)){
            spcyJcyLxService.syncGenLxUserAccount(bean.getId());
            spcyPxJbxxService.syncGenLxUserPxjl(queryJh, bean.getId());
        }

        String log = "从["+ JcyLxjhConstant.getPreviousLxjhZt(lxjhZt)+"]提交到["+lxjhZt+"]";
        spcyLogService.addLogs(LogConstant.LOGS_JCY_LXJHGL,log,bean.getId(), "遴选计划-提交", SpcyConstant.LOGS_SYS_TYPE_TJ);


        return HttpResultVo.HttpResultSave(queryJh, "提交成功");
    }

    @Log(title = "遴选计划-退回")
    @ApiOperation(value = "遴选计划-退回")
    @PostMapping(value = "returnLxjh")
    public HttpResult returnLxjh(@RequestBody SpcyPxJbxx bean){

        if (org.apache.commons.lang3.StringUtils.isBlank(bean.getId())){
            throw new BusinessException("参数为空！");
        }

        SpcyPxJbxx queryJh = spcyPxJbxxService.getById(bean.getId());
        if (queryJh == null){
            throw new BusinessException("没有相匹配的数据！");
        }

        if (org.apache.commons.lang3.StringUtils.isBlank(queryJh.getFjhzt())){
            throw new BusinessException("退回失败，参数为空！");
        }

        if (queryJh.getFjhzt().equals(JcyLxjhConstant.LX_JHZT_JHWC)){
            spcyJcyLxService.cancelSyncGenLxUserAccount(queryJh.getId());
        }

        String lxjhZt = JcyLxjhConstant.getPreviousLxjhZt(queryJh.getFjhzt());
        queryJh.setFjhzt(lxjhZt);
        spcyPxJbxxService.updateById(queryJh);

        String log = "从["+JcyLxjhConstant.getPreviousLxjhZt(lxjhZt)+"]退回到["+lxjhZt+"]";
        spcyLogService.addLogs(LogConstant.LOGS_JCY_LXJHGL,log,bean.getId(), "遴选计划-退回", SpcyConstant.LOGS_SYS_TYPE_TH);

        return HttpResult.ok("退回成功");
    }

    @Log(title = "遴选计划-根据id查看")
    @ApiOperation(value = "遴选计划-根据id查看")
    @GetMapping(value = "queryById")
    public HttpResult queryById(@RequestParam(value = "id",defaultValue = "")String id){
        if (StringEmptyUtils.isBlank(id)){
            throw new BusinessException("参数为空！");
        }
        SpcyPxJbxx jbxx = spcyPxJbxxService.getById(id);
        return HttpResult.ok(jbxx);
    }

    @Log(title = "遴选计划-删除")
    @ApiOperation(value = "遴选计划-删除")
    @DeleteMapping(value = "deleteLxjh")
    public HttpResult deleteLxjh(@RequestParam(value = "ids",defaultValue = "")String ids){
        if (org.apache.commons.lang3.StringUtils.isEmpty(ids)){
            throw new BusinessException("参数为空!");
        }

        List<String> delIdList = spcyPxJbxxService.deleteLxjh(ids);

        // 清空附件
        if (CollectionUtil.isNotEmpty(delIdList)) {
            for (String id : delIdList) {
                List<SpcySqsxWjjl> wjjlList = zdyUploadFileService.queryWjjlByPid(id);
                if (CollectionUtil.isNotEmpty(wjjlList)) {
                    for (SpcySqsxWjjl wjjl : wjjlList) {
                        zdyUploadFileService.deleteFileRecords(wjjl);
                        zdyUploadFileService.deleteFileByUrl(wjjl.getFcflj());
                    }
                }
            }
        }
        return HttpResult.ok("删除成功");
    }

    @Log(title = "遴选计划-附件上传")
    @ApiOperation(value = "遴选计划-附件上传")
    @PostMapping(value = "uploadLxjhFile")
    public HttpResult<?> uploadLxjhFile(@RequestParam("file") MultipartFile[] file,
                                        @RequestParam(value = "id",defaultValue = "")String id){
        if (StringEmptyUtils.isBlank(id)){
            throw new BusinessException("参数为空！");
        }
        SpcyPxJbxx lxjh = spcyPxJbxxService.getById(id);
        if (lxjh == null){
            throw new BusinessException("没有相匹配的数据！");
        }

        List<SpcySqsxWjjl> wjjlList = zdyUploadFileService.queryWjjlByPid(id, LogConstant.LOGS_JCY_LXJHGL);
        if (CollectionUtil.isNotEmpty(wjjlList)){
            for (SpcySqsxWjjl wjjl : wjjlList) {
                zdyUploadFileService.deleteFileRecords(wjjl);
                zdyUploadFileService.deleteFileByUrl(wjjl.getFcflj());
            }
        }

        String wjid = GetUuIdUtils.ReplaceUuId();
        zdyUploadFileService.uploadFile(file, id, LogConstant.LOGS_JCY_LXJHGL, SpcyConstant.JCY_LXJH_FILE_BASE_URL+"/"+ DateConversionUtils.DateToYear(new Date()), wjid);

        String wjHttpUrl = zdyUploadFileService.genWjllHttpUrl(wjid);
        lxjh.setFfwfjdz(wjHttpUrl);
        spcyPxJbxxService.updateById(lxjh);

        return HttpResultVo.HttpResultSave(lxjh,"上传成功");
    }

    @Log(title = "培训文件-附件上传")
    @ApiOperation(value = "培训文件-附件上传")
    @PostMapping(value = "uploadLxjhPxFile")
    public HttpResult<?> uploadLxjhPxFile(@RequestParam("file") MultipartFile[] file,
                                        @RequestParam(value = "id",defaultValue = "")String id){
        if (StringEmptyUtils.isBlank(id)){
            throw new BusinessException("参数为空！");
        }
        SpcyPxJbxx lxjh = spcyPxJbxxService.getById(id);
        if (lxjh == null){
            throw new BusinessException("没有相匹配的数据！");
        }

        List<SpcySqsxWjjl> wjjlList = zdyUploadFileService.queryWjjlByPid(id, LogConstant.LOGS_JCY_LXJHPXGL);
        if (CollectionUtil.isNotEmpty(wjjlList)){
            for (SpcySqsxWjjl wjjl : wjjlList) {
                zdyUploadFileService.deleteFileRecords(wjjl);
                zdyUploadFileService.deleteFileByUrl(wjjl.getFcflj());
            }
        }

        String wjid = GetUuIdUtils.ReplaceUuId();
        zdyUploadFileService.uploadFile(file, id, LogConstant.LOGS_JCY_LXJHPXGL, SpcyConstant.JCY_LXJH_FILE_BASE_URL+"/"+ DateConversionUtils.DateToYear(new Date()), wjid);

        String wjHttpUrl = zdyUploadFileService.genWjllHttpUrl(wjid);
        lxjh.setFpxfjdz(wjHttpUrl);
        spcyPxJbxxService.updateById(lxjh);

        return HttpResultVo.HttpResultSave(lxjh,"上传成功");
    }

    @Log(title = "查询培训试卷分页列表")
    @ApiOperation(value = "查询培训试卷分页列表")
    @GetMapping(value = "queryPxSjjbxxList")
    public HttpResult<?> queryPxSjjbxxList(SpcyPxSjjbxx query,PageVo pageVo,OrderItemVo orderItemVo){
        Page<SpcyPxSjjbxx> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());
        LambdaQueryWrapper<SpcyPxSjjbxx> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(org.apache.commons.lang3.StringUtils.isNotEmpty(query.getFsjlx()),SpcyPxSjjbxx::getFsjlx,query.getFsjlx());
        queryWrapper.like(org.apache.commons.lang3.StringUtils.isNotEmpty(query.getFsjmc()),SpcyPxSjjbxx::getFsjmc,query.getFsjmc());

        if (org.apache.commons.lang3.StringUtils.isBlank(orderItemVo.getOrderItem())){
            queryWrapper.orderByDesc(SpcyPxSjjbxx::getCreateTime);
        }else {
            OrderItemUtils.setOrderItem(queryWrapper, orderItemVo);
        }

        IPage<SpcyPxSjjbxx> pageList = spcyPxSjjbxxService.page(page, queryWrapper);

        return HttpResult.ok(pageList);
    }

    @Log(title = "保存-选择的培训试卷")
    @ApiOperation(value = "保存-选择的培训试卷")
    @GetMapping(value = "saveSelectPxsj")
    public HttpResult<?> saveSelectPxsj(@RequestParam(value = "flxjhid",defaultValue = "")String flxjhid,
                                    @RequestParam(value = "sjid",defaultValue = "") String sjid){
        if (org.apache.commons.lang3.StringUtils.isBlank(flxjhid)){
            return HttpResult.error("计划参数为空！");
        }
        if (org.apache.commons.lang3.StringUtils.isBlank(sjid)){
            return HttpResult.error("请选择试卷");
        }
        SpcyPxJbxx pxJbxx = spcyPxJbxxService.getById(flxjhid);
        if (pxJbxx == null){
            return HttpResult.error("当前培训记录不存在，请刷新重试");
        }
        pxJbxx.setFpxsjid(sjid);
        spcyPxJbxxService.updateById(pxJbxx);

        return HttpResult.ok("选择试卷成功");
    }

    @Log(title = "查询遴选选择的试卷列表")
    @ApiOperation(value = "查询遴选选择的试卷列表")
    @GetMapping(value = "querySelectLxSj")
    public HttpResult querySelectLxSj(@RequestParam(value = "flxjhid",defaultValue = "")String flxjhid){
        if (StringEmptyUtils.isBlank(flxjhid)){
            throw new BusinessException("参数为空！");
        }
        SpcyPxJbxx lx = spcyPxJbxxService.getById(flxjhid);

        String sjid = "01";
        if (lx != null && StringEmptyUtils.isNotBlank(lx.getFpxsjid())){
            sjid = lx.getFpxsjid();
        }

        LambdaQueryWrapper<SpcyPxSjjbxx> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SpcyPxSjjbxx::getId, sjid);

        List<SpcyPxSjjbxx> list = spcyPxSjjbxxService.list(queryWrapper);

        return HttpResultVo.HttpResultList(list);
    }


    @Log(title = "遴选签到场次-列表查询")
    @ApiOperation(value = "遴选签到场次-列表查询")
    @GetMapping(value = "queryLxqdccList")
    public HttpResult queryLxqdccList(@RequestParam(value = "flxjhid",defaultValue = "")String flxjhid){
        if (StringEmptyUtils.isBlank(flxjhid)){
            throw new BusinessException("参数为空！");
        }

        List<SpcyJcyLxqdcs> list = spcyJcyLxqdcsService.selectLxqdccList(flxjhid);
        return HttpResultVo.HttpResultList(list);
    }

    @Log(title = "遴选签到场次-签到记录-分页查询")
    @ApiOperation(value = "遴选签到场次-签到记录-列表查询")
    @GetMapping(value = "queryLxqdccQdjlList")
    public HttpResult queryLxqdccQdjlList(@RequestParam(value = "flxqdccid",defaultValue = "")String flxqdccid,
                                          PageVo pageVo,
                                          OrderItemVo orderItemVo){
        if (StringEmptyUtils.isBlank(flxqdccid)){
            throw new BusinessException("参数为空！");
        }
        JcyLxqdjlVo query = new JcyLxqdjlVo();
        query.setFlxqdccid(flxqdccid);
        query.setFsjshzt(JcyLxjhConstant.JCYLX_CJRY_SJSHZT_SHTG);
        Page<JcyLxqdjlVo> pageList = spcyJcyLxqdcsService.selectLxqdjlPageList(pageVo, query, orderItemVo);
        return HttpResult.ok(pageList);
    }

    /**
     * 同步签到场次-对应的签到人数数量
     */
    public void syncQdcsCjryNumber(String flxjhid){
        if (StringUtils.isBlank(flxjhid)){
            return;
        }

        List<SpcyJcyLxqdcs> qdcsList = spcyJcyLxqdcsService.list(new LambdaQueryWrapper<SpcyJcyLxqdcs>()
                .eq(SpcyJcyLxqdcs::getFlxjhid, flxjhid));
        if (CollectionUtil.isEmpty(qdcsList)){
            return;
        }

        int qdrsNumber = spcyJcyLxService.getSyncQdcsCjryNumber(flxjhid);
        for (SpcyJcyLxqdcs lxqdcs : qdcsList){
            lxqdcs.setFzqdrs(qdrsNumber);
            lxqdcs.setFzpjrs(qdrsNumber);
            spcyJcyLxqdcsService.updateById(lxqdcs);
        }

    }

    @Log(title = "遴选签到场次-新增")
    @ApiOperation(value = "遴选签到场次-新增")
    @PostMapping(value = "addLxpxqdcs")
    public HttpResult addLxpxqdcs(@RequestBody SpcyJcyLxqdcs bean){
        if (StringEmptyUtils.isBlank(bean.getFlxjhid())){
            throw new BusinessException("参数为空！");
        }
        if (StringEmptyUtils.isBlank(bean.getFqdccbt())){
            throw new BusinessException("标题为空！");
        }
        if (StringEmptyUtils.isBlank(bean.getFqdzt())){
            bean.setFqdzt(JcyLxjhConstant.JCYLX_QDCS_QDZT_BKQ);
        }
        bean.setId(GetUuIdUtils.ReplaceUuId());
        int syncQdcsCjryNumber = spcyJcyLxService.getSyncQdcsCjryNumber(bean.getFlxjhid());
        bean.setFyqdrs(0);
        bean.setFzqdrs(syncQdcsCjryNumber);

        bean.setFypjrs(0);
        bean.setFzpjrs(syncQdcsCjryNumber);
        spcyJcyLxqdcsService.save(bean);
        return HttpResultVo.HttpResultSave(bean, "新增成功");
    }

    @Log(title = "遴选签到场次-更新")
    @ApiOperation(value = "遴选签到场次-更新")
    @PutMapping(value = "updateLxpxqdcs")
    public HttpResult updateLxpxqdcs(@RequestBody SpcyJcyLxqdcs bean) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        if (StringEmptyUtils.isBlank(bean.getId())){
            throw new BusinessException("参数为空！");
        }
        SpcyJcyLxqdcs qdcs = spcyJcyLxqdcsService.getById(bean.getId());
        if (qdcs == null){
            throw new BusinessException("没有相匹配的数据！");
        }
        ConvertUtils.register(new DateConvert(), java.util.Date.class);
        BeanUtils.populate(bean, BeanUtils.describe(bean));
        spcyJcyLxqdcsService.updateById(bean);
        return HttpResult.ok("保存成功");
    }

    @Log(title = "遴选签到场次-删除")
    @ApiOperation(value = "遴选签到场次-删除")
    @DeleteMapping(value = "deleteLxpxqdcs")
    public HttpResult deleteLxpxqdcs(@RequestParam(value = "id",defaultValue = "")String id){
        if (StringEmptyUtils.isBlank(id)){
            throw new BusinessException("参数为空！");
        }

        List<SpcyJcyLxqdjl> qdjlList = spcyJcyLxqdcsService.selectLxqdcsQdjl(id);
        if (CollectionUtil.isNotEmpty(qdjlList)){
            return HttpResult.error("删除失败，已经存在相关人员的签到记录！");
        }

        SpcyJcyLxqdcs lxqdcs = spcyJcyLxqdcsService.getById(id);
        if (lxqdcs == null){
            throw new BusinessException("没有相匹配的数据！");
        }
        spcyJcyLxqdcsService.deleteLxpxqdcs(id);

        List<SpcyJcyLxpxls> list = spcyJcyLxpxlsService.list(new LambdaQueryWrapper<SpcyJcyLxpxls>()
                .eq(SpcyJcyLxpxls::getFlxqdccid, id));
        if (CollectionUtil.isNotEmpty(list)){
            spcyJcyLxpxlsService.remove(new LambdaQueryWrapper<SpcyJcyLxpxls>()
                    .eq(SpcyJcyLxpxls::getFlxqdccid, id));

            List<String> pxlsIdList = list.stream().map(SpcyJcyLxpxls::getId).collect(Collectors.toList());
            spcyJcyLxjsjxpjService.remove(new LambdaQueryWrapper<SpcyJcyLxjsjxpj>()
                    .in(SpcyJcyLxjsjxpj::getFpxlsid, pxlsIdList));
        }

        String operContent = "删除信息：";
        operContent += LogUtils.MapToStringMethod(ObjectToMapUtils.objectToMap(lxqdcs));
        spcyLogService.addLogs(LogConstant.LOGS_JCY_LXJHGL,operContent,lxqdcs.getFlxjhid(), "遴选签到场次-删除", SpcyConstant.LOGS_SYS_TYPE_XZ);

        return HttpResult.ok("删除成功");
    }

    @Log(title = "签到记录设置备注")
    @ApiOperation(value = "签到记录设置备注")
    @PostMapping(value = "szqdjlbz")
    public HttpResult szqdjlbz(@RequestBody JcyLxqdjlVo bean){
        if (StringUtils.isBlank(bean.getId())){
            throw new BusinessException("人员为空！");
        }
        if (StringUtils.isBlank(bean.getFlxqdccid())){
            throw new BusinessException("参数为空！");
        }

        spcyJcyLxqdcsService.initGenQdjlInShtg(bean.getId(), bean.getFlxqdccid(), bean.getFbz(), bean.getFqdsj(),  true);

        return HttpResult.ok("设置成功");
    }


    @ApiOperation(value = "培训场次老师-列表查询")
    @GetMapping(value = "queryPxlsList")
    public HttpResult queryPxlsList(@RequestParam(value = "flxqdccid",defaultValue = "0")String flxqdccid,
                                    @RequestParam(value = "gjz",defaultValue = "")String gjz,
                                    PageVo pageVo){

        Page<SpcyJcyLxpxls> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());

        LambdaQueryWrapper<SpcyJcyLxpxls> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SpcyJcyLxpxls::getFlxqdccid, flxqdccid);
        if (StringUtils.isNotBlank(gjz)){
            queryWrapper.and(q -> q.like(SpcyJcyLxpxls::getFjsxm, gjz)
                    .or()
                    .like(SpcyJcyLxpxls::getFjspxnr, gjz)
            );
        }
        Page<SpcyJcyLxpxls> pageList = spcyJcyLxpxlsService.page(page, queryWrapper);
        return HttpResult.ok(pageList);
    }

    @Log(title = "培训场次老师-添加")
    @ApiOperation(value = "培训场次老师-添加")
    @PostMapping(value = "addPxls")
    public HttpResult addPxls(@RequestBody SpcyJcyLxpxls bean){
        if (StringUtils.isBlank(bean.getFlxqdccid())){
            throw new BusinessException("场次参数为空！");
        }

        if (StringUtils.isBlank(bean.getFjsxm())){
            throw new BusinessException("教师姓名为空！");
        }

        if (StringUtils.isBlank(bean.getFjspxnr())){
            throw new BusinessException("培训内容为空！");
        }

        SpcyJcyLxqdcs qdcs = spcyJcyLxqdcsService.getById(bean.getFlxqdccid());
        if (qdcs == null){
            throw new BusinessException("没有相匹配的数据！");
        }
        bean.setFjsxm(StringPatternUtils.trimString(bean.getFjsxm()));

        List<SpcyJcyLxpxls> pxlsList = spcyJcyLxpxlsService.list(new LambdaQueryWrapper<SpcyJcyLxpxls>()
                .eq(SpcyJcyLxpxls::getFlxqdccid, bean.getFlxqdccid())
                .eq(SpcyJcyLxpxls::getFjsxm, bean.getFjsxm()));
        if (CollectionUtil.isNotEmpty(pxlsList)){
            throw new BusinessException("已经存在对应的老师！");
        }

        bean.setFlxjhid(qdcs.getFlxjhid());
        bean.setId(GetUuIdUtils.ReplaceUuId());
        bean.setCreateTime(new Date());
        spcyJcyLxpxlsService.save(bean);

        // 场次
        String fccpxls = qdcs.getFccpxls();
        if (StringUtils.isBlank(fccpxls)){
            fccpxls = bean.getFjsxm();
        }else {
            fccpxls += "," + bean.getFjsxm();
        }
        qdcs.setFccpxls(fccpxls);
        spcyJcyLxqdcsService.updateById(qdcs);

        return HttpResult.ok("添加成功");
    }

    @Log(title = "培训场次老师-更新")
    @ApiOperation(value = "培训场次老师-更新")
    @PutMapping(value = "updatePxls")
    public HttpResult updatePxls(@RequestBody HashMap<String,String> buffer) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        if (StringEmptyUtils.isBlank(buffer.get("id"))){
            throw new BusinessException("参数为空！");
        }

        SpcyJcyLxpxls updateBean = spcyJcyLxpxlsService.getById(buffer.get("id"));
        if (updateBean == null){
            throw new BusinessException("没有相匹配的数据！");
        }
        String flxqdccid = updateBean.getFlxqdccid();

        ConvertUtils.register(new DateConvert(), java.util.Date.class);
        BeanUtils.populate(updateBean, buffer);
        spcyJcyLxpxlsService.updateById(updateBean);

        // 场次
        List<SpcyJcyLxpxls> pxlsList = spcyJcyLxpxlsService.list(new LambdaQueryWrapper<SpcyJcyLxpxls>()
                .eq(SpcyJcyLxpxls::getFlxqdccid, flxqdccid));
        if (CollectionUtil.isNotEmpty(pxlsList)){
            String pxlsname = "";
            for (SpcyJcyLxpxls lxpxls : pxlsList){
                if (StringUtils.isBlank(pxlsname)){
                    pxlsname += lxpxls.getFjsxm();
                }else {
                    pxlsname += "," + lxpxls.getFjsxm();
                }
            }

            LambdaUpdateWrapper<SpcyJcyLxqdcs> updateWrapperCc = new LambdaUpdateWrapper<>();
            updateWrapperCc.eq(SpcyJcyLxqdcs::getId, flxqdccid);

            SpcyJcyLxqdcs updateCc = new SpcyJcyLxqdcs();
            updateCc.setFccpxls(pxlsname);

            spcyJcyLxqdcsService.update(updateCc, updateWrapperCc);

        }

        return HttpResult.ok("保存成功");
    }

    @Log(title = "培训场次老师-删除")
    @ApiOperation(value = "培训场次老师-删除")
    @DeleteMapping(value = "deletePxls")
    public HttpResult deletePxls(@RequestParam(value = "id",defaultValue = "")String id){
        if (StringEmptyUtils.isBlank(id)){
            throw new BusinessException("参数为空！");
        }

        SpcyJcyLxpxls bean = spcyJcyLxpxlsService.getById(id);
        if (bean == null){
            throw new BusinessException("没有相匹配的数据！");
        }

        spcyJcyLxpxlsService.removeById(id);
        spcyJcyLxjsjxpjService.remove(new LambdaQueryWrapper<SpcyJcyLxjsjxpj>()
                .eq(SpcyJcyLxjsjxpj::getFpxlsid, id));

        // 场次
        List<SpcyJcyLxpxls> pxlsList = spcyJcyLxpxlsService.list(new LambdaQueryWrapper<SpcyJcyLxpxls>()
                .eq(SpcyJcyLxpxls::getFlxqdccid, bean.getFlxqdccid()));
        String pxlsname = "";
        if (CollectionUtil.isNotEmpty(pxlsList)){
            for (SpcyJcyLxpxls lxpxls : pxlsList){
                if (StringUtils.isBlank(pxlsname)){
                    pxlsname += lxpxls.getFjsxm();
                }else {
                    pxlsname += "," + lxpxls.getFjsxm();
                }
            }
        }

        // 更新
        LambdaUpdateWrapper<SpcyJcyLxqdcs> updateWrapperCc = new LambdaUpdateWrapper<>();
        updateWrapperCc.eq(SpcyJcyLxqdcs::getId, bean.getFlxqdccid());

        SpcyJcyLxqdcs updateCc = new SpcyJcyLxqdcs();
        updateCc.setFccpxls(pxlsname);
        spcyJcyLxqdcsService.update(updateCc, updateWrapperCc);

        String operContent = "删除信息：";
        operContent += LogUtils.MapToStringMethod(ObjectToMapUtils.objectToMap(bean));
        spcyLogService.addLogs(LogConstant.LOGS_JCY_LXJHGL,operContent,bean.getFlxjhid(), "培训场次老师-删除", SpcyConstant.LOGS_SYS_TYPE_XZ);

        return HttpResult.ok("删除成功");
    }

    @Log(title = "遴选采集人员-个状态数量")
    @ApiOperation(value = "遴选采集人员-个状态数量")
    @GetMapping(value = "getLxUserGztsl")
    public HttpResult getLxUserGztsl(@RequestParam(value = "flxjhid",defaultValue = "")String flxjhid){
        if (StringEmptyUtils.isBlank(flxjhid)){
            throw new BusinessException("参数为空！");
        }

        // 报名人员汇总
        JcyLxUserVo query = new JcyLxUserVo();
        query.setFlxjhid(flxjhid);
        query.setRyhzzt(JcyLxjhConstant.JCYLX_CJRY_SJSHZT_WSH);
        List<JcyLxUserVo> hzryList = spcyPxJbxxMapper.selectLxjhryList(query);

        // 所有遴选人员列表
        JcyLxUserVo query2 = new JcyLxUserVo();
        query2.setFlxjhid(flxjhid);
        List<JcyLxUserVo> lxUserList = spcyPxJbxxMapper.selectLxjhryList(query2);

        // 待审核-人员列表
        JcyLxUserVo dshQury = new JcyLxUserVo();
        dshQury.setFlxjhid(flxjhid);
        dshQury.setFsjcjzt(JcydjbConstant.LX_SJCJZT_YWC);
        dshQury.setFsjshzt(JcyLxjhConstant.JCYLX_CJRY_SJSHZT_WSH);
        List<JcyLxUserVo> dshryList = spcyPxJbxxMapper.selectLxjhryList(dshQury);


        int dsh = dshryList.size(); // 待审核
        int shtg = 0; // 审核通过
        int shbtg = 0; // 审核不通过
        int thxg = 0; // 退回修改
        int ryhz = hzryList.size(); // 报名人员汇总
        int rqmd = 0;  // 最终确认名单

        if (CollectionUtil.isNotEmpty(lxUserList)){

            shtg = lxUserList.stream()
                    .filter( f -> StringEmptyUtils.isNotBlank(f.getFsjshzt()) && f.getFsjshzt().equals(JcyLxjhConstant.JCYLX_CJRY_SJSHZT_SHTG))
                    .collect(Collectors.toList())
                    .size();

            shbtg = lxUserList.stream()
                    .filter( f -> StringEmptyUtils.isNotBlank(f.getFsjshzt()) && f.getFsjshzt().equals(JcyLxjhConstant.JCYLX_CJRY_SJSHZT_SHBTG))
                    .collect(Collectors.toList())
                    .size();

            rqmd = lxUserList.stream()
                    .filter( f -> StringEmptyUtils.isNotBlank(f.getFsjshzt())
                            && StringEmptyUtils.isNotBlank(f.getFkhjg())
                            && f.getFsjshzt().equals(JcyLxjhConstant.JCYLX_CJRY_SJSHZT_SHTG)
                            && f.getFkhjg().equals(JcyLxjhConstant.JCYLX_CJRY_KHJG_HG)
                    )
                    .collect(Collectors.toList())
                    .size();
        }

        Map resultMap = new HashMap<>();

        resultMap.put("dsh", dsh);

        resultMap.put("shtg", shtg);

        resultMap.put("shbtg", shbtg);

        resultMap.put("thxg", thxg);

        resultMap.put("ryhz", ryhz);

        resultMap.put("rqmd", rqmd);

        return HttpResult.ok(resultMap);
    }

    @Log(title = "待审核-遴选采集人员-分页列表")
    @ApiOperation(value = "待审核-遴选采集人员-分页列表")
    @GetMapping(value = "dshLxUserPageList")
    public HttpResult dshLxUserPageList(JcyLxUserVo query, PageVo pageVo, OrderItemVo orderItemVo){
        Page<JcyLxUserVo> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());

        if (StringEmptyUtils.isBlank(query.getFlxjhid())){
            throw new BusinessException("遴选参数为空！");
        }

        query = spcyJcyLxService.ZhQueryTj(query, 0);

        return HttpResult.ok(spcyPxJbxxMapper.selectLxjhUserPageList(page, query, orderItemVo));
    }

    @Log(title = "审核通过-遴选采集人员-分页列表")
    @ApiOperation(value = "审核通过-遴选采集人员-分页列表")
    @GetMapping(value = "shtgLxUserPageList")
    public HttpResult shtgLxUserPageList(JcyLxUserVo query, PageVo pageVo, OrderItemVo orderItemVo){
        Page<JcyLxUserVo> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());
        if (StringEmptyUtils.isBlank(query.getFlxjhid())){
            throw new BusinessException("遴选参数为空！");
        }

        query = spcyJcyLxService.ZhQueryTj(query, 1);

        return HttpResult.ok(spcyPxJbxxMapper.selectLxjhUserPageList(page, query, orderItemVo));
    }

    @Log(title = "审核不通过-遴选采集人员-分页列表")
    @ApiOperation(value = "审核不通过-遴选采集人员-分页列表")
    @GetMapping(value = "shbtgLxUserPageList")
    public HttpResult shbtgLxUserPageList(JcyLxUserVo query, PageVo pageVo, OrderItemVo orderItemVo){
        Page<JcyLxUserVo> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());
        if (StringEmptyUtils.isBlank(query.getFlxjhid())){
            throw new BusinessException("遴选参数为空！");
        }

        query = spcyJcyLxService.ZhQueryTj(query, 2);

        return HttpResult.ok(spcyPxJbxxMapper.selectLxjhUserPageList(page, query, orderItemVo));
    }

    /*@Log(title = "退回修改-遴选采集人员-分页列表")
    @ApiOperation(value = "退回修改-遴选采集人员-分页列表")*/
    @GetMapping(value = "thxgLxUserPageList")
    public HttpResult thxgLxUserPageList(JcyLxUserVo query, PageVo pageVo, OrderItemVo orderItemVo){
        Page<JcyLxUserVo> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());
        if (StringEmptyUtils.isBlank(query.getFlxjhid())){
            throw new BusinessException("遴选参数为空！");
        }

        if (StringUtils.isNotBlank(query.getGjz())){
            if (query.getGjz().contains("男")){
                query.setSex(1);
            }else if (query.getGjz().contains("女")){
                query.setSex(2);
            }
        }

        query.setFsjshzt(JcyLxjhConstant.JCYLX_CJRY_SJSHZT_THXG);
        return HttpResult.ok(spcyPxJbxxMapper.selectLxjhUserPageList(page, query, orderItemVo));
    }

    @Log(title = "报名人员汇总-遴选采集人员-分页列表")
    @ApiOperation(value = "报名人员汇总-遴选采集人员-分页列表")
    @GetMapping(value = "bmryhzLxUserPageList")
    public HttpResult bmryhzLxUserPageList(JcyLxUserVo query, PageVo pageVo, OrderItemVo orderItemVo){
        Page<JcyLxUserVo> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());
        if (StringEmptyUtils.isBlank(query.getFlxjhid())){
            throw new BusinessException("遴选参数为空！");
        }

        query = spcyJcyLxService.ZhQueryTj(query, 3);

        return HttpResult.ok(spcyPxJbxxMapper.selectLxjhUserPageList(page, query, orderItemVo));
    }

    @Log(title = "人员考核列表-遴选采集人员-分页列表")
    @ApiOperation(value = "人员考核列表-遴选采集人员-分页列表")
    @GetMapping(value = "rykhlbLxUserPageList")
    public HttpResult rykhlbLxUserPageList(JcyLxUserVo query, PageVo pageVo, OrderItemVo orderItemVo){
        Page<JcyLxUserVo> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());
        if (StringEmptyUtils.isBlank(query.getFlxjhid())){
            throw new BusinessException("遴选参数为空！");
        }

        query = spcyJcyLxService.ZhQueryTj(query, 4);

        return HttpResult.ok(spcyPxJbxxMapper.selectLxjhUserPageList(page, query, orderItemVo));
    }

    @Log(title = "最终确认名单-遴选采集人员-分页列表")
    @ApiOperation(value = "最终确认名单-遴选采集人员-分页列表")
    @GetMapping(value = "zzqrmdLxUserPageList")
    public HttpResult zzqrmdLxUserPageList(JcyLxUserVo query, PageVo pageVo, OrderItemVo orderItemVo){
        Page<JcyLxUserVo> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());
        if (StringEmptyUtils.isBlank(query.getFlxjhid())){
            throw new BusinessException("遴选参数为空！");
        }

        query = spcyJcyLxService.ZhQueryTj(query, 5);

        return HttpResult.ok(spcyPxJbxxMapper.selectLxjhUserPageList(page, query, orderItemVo));
    }

    /*@Log(title = "遴选采集人员-退回修改")
    @ApiOperation(value = "遴选采集人员-退回修改")*/
    @PostMapping(value = "updateLxUserThxg")
    public HttpResult updateLxUserThxg(@RequestBody ParamsBo paramsBo){
        spcyJcyLxService.updateLxUserThxg(paramsBo.getIds(), paramsBo.getOpinion());

        return HttpResult.ok("退回成功");
    }

    @Log(title = "遴选采集人员-审核通过")
    @ApiOperation(value = "遴选采集人员-审核通过")
    @PostMapping(value = "updateLxUserShtg")
    public HttpResult updateLxUserShtg(@RequestBody ParamsBo paramsBo){
        spcyJcyLxService.updateLxUserShtg(paramsBo.getIds());

        return HttpResult.ok("审核成功");
    }

    @Log(title = "遴选采集人员-审核不通过")
    @ApiOperation(value = "遴选采集人员-审核不通过")
    @PostMapping(value = "updateLxUserShbtg")
    public HttpResult updateLxUserShbtg(@RequestBody ParamsBo paramsBo){
        spcyJcyLxService.updateLxUserShbtg(paramsBo.getIds(), paramsBo.getOpinion());

        return HttpResult.ok("审核成功");
    }

    @Log(title = "遴选采集人员-设置考核结果")
    @ApiOperation(value = "遴选采集人员-设置考核结果")
    @PostMapping(value = "updateLxUserKhjg")
    public HttpResult updateLxUserKhjg(@RequestBody JcyLxKhjgBo paramsBo){
        spcyJcyLxService.updateLxUserKhjg(paramsBo);

        return HttpResult.ok("设置成功");
    }

    @Log(title = "获取报名人员答卷id")
    @ApiOperation(value = "获取报名人员答卷id")
    @GetMapping(value = "getCjryDjidByCjryId")
    public HttpResult getCjryDjidByCjryId(@RequestParam(value = "id",defaultValue = "")String id){

        return HttpResult.ok(spcyJcyLxService.getCjryDjidByCjryId(id));
    }

    @Log(title = "导出-遴选采集人员-待审核")
    @ApiOperation(value = "导出-遴选采集人员-待审核")
    @GetMapping(value = "exportLxUserInDsh")
    public void exportLxUserInDsh(JcyLxUserVo query, OrderItemVo orderItemVo, HttpServletResponse response){
        if(StringUtils.isBlank(query.getIds())) {
            if (StringEmptyUtils.isBlank(query.getFlxjhid())) {
                throw new BusinessException("遴选参数为空！");
            }

            query = spcyJcyLxService.ZhQueryTj(query, 0);

        }

        String[] titles = new String[]{"序号", "姓名", "性别", "工作单位","工作单位部门","学历","专业","从事专业工作年限", "联系电话"};
        List<List<String>> resultList = new ArrayList<>();

        resultList.add(CollectionUtil.newArrayList(titles));

        List<String> dataList = null;

        List<JcyLxUserVo> userList = spcyPxJbxxMapper.selectLxjhUserList(query, orderItemVo);
        for (int order = 0; order < userList.size(); order++){
            dataList = new ArrayList<>();

            dataList.add(String.valueOf(order+1));

            dataList.add(userList.get(order).getRealname());
//            dataList.add(userList.get(order).getFsfzh());

            String sex = "";
            if (userList.get(order).getSex() != null){
                if (userList.get(order).getSex().equals(1)){
                    sex = "男";
                }else if (userList.get(order).getSex().equals(2)){
                    sex = "女";
                }
            }
            dataList.add(sex);

            dataList.add(userList.get(order).getFgzdw());
            dataList.add(userList.get(order).getFgzdwbm());

            dataList.add(userList.get(order).getFxl());
            dataList.add(userList.get(order).getFsxzy());

            dataList.add(userList.get(order).getFgznx());
            dataList.add(userList.get(order).getPhone());

            resultList.add(dataList);
        }

        // 文件名称
        String title = "名单";
        ExcelUtils.getLocalTitleExcel(resultList,title,response);
    }

    @Log(title = "导出-遴选采集人员-审核通过")
    @ApiOperation(value = "导出-遴选采集人员-审核通过")
    @GetMapping(value = "exportLxUserInShtg")
    public void exportLxUserInShtg(JcyLxUserVo query, OrderItemVo orderItemVo, HttpServletResponse response){
        if (StringUtils.isBlank(query.getIds())) {
            if (StringEmptyUtils.isBlank(query.getFlxjhid())) {
                throw new BusinessException("遴选参数为空！");
            }

            query = spcyJcyLxService.ZhQueryTj(query, 1);
        }

        String[] titles = new String[]{"序号", "姓名", "性别", "工作单位","工作单位部门","学历","专业","从事专业工作年限", "联系电话"};
        List<List<String>> resultList = new ArrayList<>();

        resultList.add(CollectionUtil.newArrayList(titles));

        List<String> dataList = null;

        List<JcyLxUserVo> userList = spcyPxJbxxMapper.selectLxjhUserList(query, orderItemVo);
        for (int order = 0; order < userList.size(); order++){
            dataList = new ArrayList<>();

            dataList.add(String.valueOf(order+1));

            dataList.add(userList.get(order).getRealname());
//            dataList.add(userList.get(order).getFsfzh());

            String sex = "";
            if (userList.get(order).getSex() != null){
                if (userList.get(order).getSex().equals(1)){
                    sex = "男";
                }else if (userList.get(order).getSex().equals(2)){
                    sex = "女";
                }
            }
            dataList.add(sex);

            dataList.add(userList.get(order).getFgzdw());
            dataList.add(userList.get(order).getFgzdwbm());

            dataList.add(userList.get(order).getFxl());
            dataList.add(userList.get(order).getFsxzy());

            dataList.add(userList.get(order).getFgznx());
            dataList.add(userList.get(order).getPhone());

            resultList.add(dataList);
        }

        // 文件名称
        String title = "名单";
        ExcelUtils.getLocalTitleExcel(resultList,title,response);
    }

    @Log(title = "导出-遴选采集人员-审核不通过")
    @ApiOperation(value = "导出-遴选采集人员-审核不通过")
    @GetMapping(value = "exportLxUserInShbtg")
    public void exportLxUserInShbtg(JcyLxUserVo query, OrderItemVo orderItemVo, HttpServletResponse response){
        if (StringUtils.isBlank(query.getIds())) {
            if (StringEmptyUtils.isBlank(query.getFlxjhid())) {
                throw new BusinessException("遴选参数为空！");
            }

            query = spcyJcyLxService.ZhQueryTj(query, 2);
        }

        String[] titles = new String[]{"序号", "姓名", "性别", "工作单位","工作单位部门","学历","专业","从事专业工作年限", "联系电话", "原因"};
        List<List<String>> resultList = new ArrayList<>();

        resultList.add(CollectionUtil.newArrayList(titles));

        List<String> dataList = null;

        List<JcyLxUserVo> userList = spcyPxJbxxMapper.selectLxjhUserList(query, orderItemVo);
        for (int order = 0; order < userList.size(); order++){
            dataList = new ArrayList<>();

            dataList.add(String.valueOf(order+1));

            dataList.add(userList.get(order).getRealname());
//            dataList.add(userList.get(order).getFsfzh());

            String sex = "";
            if (userList.get(order).getSex() != null){
                if (userList.get(order).getSex().equals(1)){
                    sex = "男";
                }else if (userList.get(order).getSex().equals(2)){
                    sex = "女";
                }
            }
            dataList.add(sex);

            dataList.add(userList.get(order).getFgzdw());
            dataList.add(userList.get(order).getFgzdwbm());

            dataList.add(userList.get(order).getFxl());
            dataList.add(userList.get(order).getFsxzy());

            dataList.add(userList.get(order).getFgznx());
            dataList.add(userList.get(order).getPhone());
            dataList.add(userList.get(order).getFbz());

            resultList.add(dataList);
        }

        // 文件名称
        String title = "名单";
        ExcelUtils.getLocalTitleExcel(resultList,title,response);
    }

    /*@Log(title = "导出-遴选采集人员-退回修改")
    @ApiOperation(value = "导出-遴选采集人员-退回修改")*/
    @GetMapping(value = "exportLxUserInThxg")
    public void exportLxUserInThxg(JcyLxUserVo query, OrderItemVo orderItemVo, HttpServletResponse response){
        if (StringUtils.isBlank(query.getIds())) {
            if (StringEmptyUtils.isBlank(query.getFlxjhid())) {
                throw new BusinessException("遴选参数为空！");
            }

            query.setFsjshzt(JcyLxjhConstant.JCYLX_CJRY_SJSHZT_THXG);

            if (StringUtils.isNotBlank(query.getGjz())){
                if (query.getGjz().contains("男")){
                    query.setSex(1);
                }else if (query.getGjz().contains("女")){
                    query.setSex(2);
                }
            }
        }

        String[] titles = new String[]{"序号", "姓名", "性别", "工作单位","工作单位部门","学历","专业","从事专业工作年限", "联系电话", "原因"};
        List<List<String>> resultList = new ArrayList<>();

        resultList.add(CollectionUtil.newArrayList(titles));

        List<String> dataList = null;

        List<JcyLxUserVo> userList = spcyPxJbxxMapper.selectLxjhUserList(query, orderItemVo);
        for (int order = 0; order < userList.size(); order++){
            dataList = new ArrayList<>();

            dataList.add(String.valueOf(order+1));

            dataList.add(userList.get(order).getRealname());
//            dataList.add(userList.get(order).getFsfzh());

            String sex = "";
            if (userList.get(order).getSex() != null){
                if (userList.get(order).getSex().equals(1)){
                    sex = "男";
                }else if (userList.get(order).getSex().equals(2)){
                    sex = "女";
                }
            }
            dataList.add(sex);

            dataList.add(userList.get(order).getFgzdw());
            dataList.add(userList.get(order).getFgzdwbm());

            dataList.add(userList.get(order).getFxl());
            dataList.add(userList.get(order).getFsxzy());

            dataList.add(userList.get(order).getFgznx());
            dataList.add(userList.get(order).getPhone());
            dataList.add(userList.get(order).getFbz());

            resultList.add(dataList);
        }

        // 文件名称
        String title = "名单";
        ExcelUtils.getLocalTitleExcel(resultList,title,response);
    }

    @Log(title = "导出-遴选采集人员-人员汇总导出")
    @ApiOperation(value = "导出-遴选采集人员-人员汇总导出")
    @GetMapping(value = "exportLxUserByRyHz")
    public void exportLxUserByRyHz(JcyLxUserVo query, OrderItemVo orderItemVo, HttpServletResponse response){
        if (StringUtils.isBlank(query.getIds())) {
            if (StringEmptyUtils.isBlank(query.getFlxjhid())) {
                throw new BusinessException("遴选参数为空！");
            }

            query = spcyJcyLxService.ZhQueryTj(query, 3);
        }

        String[] titles = new String[]{"序号", "姓名", "性别", "工作单位","工作单位部门","学历","专业","从事专业工作年限", "联系电话", "审核状态"};
        List<List<String>> resultList = new ArrayList<>();

        resultList.add(CollectionUtil.newArrayList(titles));

        List<String> dataList = null;

        List<JcyLxUserVo> userList = spcyPxJbxxMapper.selectLxjhUserList(query, orderItemVo);
        for (int order = 0; order < userList.size(); order++){
            dataList = new ArrayList<>();

            dataList.add(String.valueOf(order+1));

            dataList.add(userList.get(order).getRealname());
//            dataList.add(userList.get(order).getFsfzh());

            String sex = "";
            if (userList.get(order).getSex() != null){
                if (userList.get(order).getSex().equals(1)){
                    sex = "男";
                }else if (userList.get(order).getSex().equals(2)){
                    sex = "女";
                }
            }
            dataList.add(sex);

            dataList.add(userList.get(order).getFgzdw());
            dataList.add(userList.get(order).getFgzdwbm());

            dataList.add(userList.get(order).getFxl());
            dataList.add(userList.get(order).getFsxzy());

            dataList.add(userList.get(order).getFgznx());
            dataList.add(userList.get(order).getPhone());

            dataList.add(userList.get(order).getFsjshzt());

            resultList.add(dataList);
        }

        // 文件名称
        String title = "名单";
        ExcelUtils.getLocalTitleExcel(resultList,title,response);
    }

    @Log(title = "导出-遴选采集人员-人员考核列表")
    @ApiOperation(value = "导出-遴选采集人员-人员考核列表")
    @GetMapping(value = "exportLxUserInRykhlb")
    public void exportLxUserInRykhlb(JcyLxUserVo query, OrderItemVo orderItemVo, HttpServletResponse response){
        if (StringUtils.isBlank(query.getIds())) {
            if (StringEmptyUtils.isBlank(query.getFlxjhid())) {
                throw new BusinessException("遴选参数为空！");
            }

            query = spcyJcyLxService.ZhQueryTj(query, 4);
        }

        String[] titles = new String[]{"序号", "姓名", "性别", "工作单位","工作单位部门","学历","专业","从事专业工作年限", "联系电话", "考核分数", "考核结果"};
        List<List<String>> resultList = new ArrayList<>();

        resultList.add(CollectionUtil.newArrayList(titles));

        List<String> dataList = null;

        List<JcyLxUserVo> userList = spcyPxJbxxMapper.selectLxjhUserList(query, orderItemVo);
        for (int order = 0; order < userList.size(); order++){
            dataList = new ArrayList<>();

            dataList.add(String.valueOf(order+1));

            dataList.add(userList.get(order).getRealname());
//            dataList.add(userList.get(order).getFsfzh());

            String sex = "";
            if (userList.get(order).getSex() != null){
                if (userList.get(order).getSex().equals(1)){
                    sex = "男";
                }else if (userList.get(order).getSex().equals(2)){
                    sex = "女";
                }
            }
            dataList.add(sex);

            dataList.add(userList.get(order).getFgzdw());
            dataList.add(userList.get(order).getFgzdwbm());

            dataList.add(userList.get(order).getFxl());
            dataList.add(userList.get(order).getFsxzy());

            dataList.add(userList.get(order).getFgznx());
            dataList.add(userList.get(order).getPhone());

            dataList.add(userList.get(order).getFksfs());
            dataList.add(userList.get(order).getFkhjg());

            resultList.add(dataList);
        }

        // 文件名称
        String title = "名单";
        ExcelUtils.getLocalTitleExcel(resultList,title,response);
    }

    @Log(title = "导出-遴选采集人员-最终确认名单")
    @ApiOperation(value = "导出-遴选采集人员-最终确认名单")
    @GetMapping(value = "exportLxUserInZzqrmd")
    public void exportLxUserInZzqrmd(JcyLxUserVo query, OrderItemVo orderItemVo, HttpServletResponse response){
        if (StringUtils.isBlank(query.getIds())) {
            if (StringEmptyUtils.isBlank(query.getFlxjhid())) {
                throw new BusinessException("遴选参数为空！");
            }

            query = spcyJcyLxService.ZhQueryTj(query, 5);
        }

        String[] titles = new String[]{"序号", "姓名", "性别", "工作单位","工作单位部门","学历","专业","从事专业工作年限", "联系电话", "考核分数", "考核结果"};
        List<List<String>> resultList = new ArrayList<>();

        resultList.add(CollectionUtil.newArrayList(titles));

        List<String> dataList = null;

        List<JcyLxUserVo> userList = spcyPxJbxxMapper.selectLxjhUserList(query, orderItemVo);
        for (int order = 0; order < userList.size(); order++){
            dataList = new ArrayList<>();

            dataList.add(String.valueOf(order+1));

            dataList.add(userList.get(order).getRealname());
//            dataList.add(userList.get(order).getFsfzh());

            String sex = "";
            if (userList.get(order).getSex() != null){
                if (userList.get(order).getSex().equals(1)){
                    sex = "男";
                }else if (userList.get(order).getSex().equals(2)){
                    sex = "女";
                }
            }
            dataList.add(sex);

            dataList.add(userList.get(order).getFgzdw());
            dataList.add(userList.get(order).getFgzdwbm());

            dataList.add(userList.get(order).getFxl());
            dataList.add(userList.get(order).getFsxzy());

            dataList.add(userList.get(order).getFgznx());
            dataList.add(userList.get(order).getPhone());

            dataList.add(userList.get(order).getFksfs());
            dataList.add(userList.get(order).getFkhjg());

            resultList.add(dataList);
        }

        // 文件名称
        String title = "名单";
        ExcelUtils.getLocalTitleExcel(resultList,title,response);
    }

    @Log(title = "导出ZIP-遴选采集人员-待审核")
    @ApiOperation(value = "导出ZIP-遴选采集人员-待审核")
    @GetMapping(value = "exportZipLxryInDsh")
    public void exportZipLxryInDsh(JcyLxUserVo query, OrderItemVo orderItemVo, HttpServletResponse response){

        spcyJcyLxService.exportZipLxry(query, orderItemVo,0, response);
    }

    @Log(title = "导出ZIP-遴选采集人员-审核通过")
    @ApiOperation(value = "导出ZIP-遴选采集人员-审核通过")
    @GetMapping(value = "exportZipLxryInShtg")
    public void exportZipLxryInShtg(JcyLxUserVo query, OrderItemVo orderItemVo, HttpServletResponse response){

        spcyJcyLxService.exportZipLxry(query, orderItemVo,1, response);
    }

    @Log(title = "导出ZIP-遴选采集人员-审核不通过")
    @ApiOperation(value = "导出ZIP-遴选采集人员-审核不通过")
    @GetMapping(value = "exportZipLxryInShbtg")
    public void exportZipLxryInShbtg(JcyLxUserVo query, OrderItemVo orderItemVo, HttpServletResponse response){

        spcyJcyLxService.exportZipLxry(query, orderItemVo,2, response);
    }

    @Log(title = "导出ZIP-遴选采集人员-人员汇总")
    @ApiOperation(value = "导出ZIP-遴选采集人员-人员汇总")
    @GetMapping(value = "exportZipLxryInRyhz")
    public void exportZipLxryInRyhz(JcyLxUserVo query, OrderItemVo orderItemVo, HttpServletResponse response){

        spcyJcyLxService.exportZipLxry(query, orderItemVo,3, response);
    }

    @Log(title = "打印列表-遴选采集人员-最终确认名单")
    @ApiOperation(value = "打印列表-遴选采集人员-最终确认名单")
    @GetMapping(value = "printLxryInZzqrmd")
    public HttpResult printLxryInZzqrmd(JcyLxUserVo query, OrderItemVo orderItemVo){

        if (StringUtils.isBlank(query.getIds())) {
            query = spcyJcyLxService.ZhQueryTj(query, 5);
        }

        List<JcyLxUserVo> list = spcyPxJbxxMapper.selectLxjhUserList(query, orderItemVo);

        return HttpResult.ok(list);
    }

    @Log(title = "获取最终确认名单人数")
    @ApiOperation(value = "获取最终确认名单人数")
    @GetMapping(value = "getZzqrmdRs")
    public HttpResult getZzqrmdRs(@RequestParam(value = "flxjhid",defaultValue = "")String flxjhid){
        if (StringUtils.isBlank(flxjhid)){
            throw new BusinessException("参数为空！");
        }
        JcyLxUserVo query = new JcyLxUserVo();
        query = spcyJcyLxService.ZhQueryTj(query, 5);

        query.setFlxjhid(flxjhid);
        List<JcyLxUserVo> list = spcyPxJbxxMapper.selectLxjhUserList(query, new OrderItemVo());

        Map resultMap = new HashMap();
        resultMap.put("number", list.size());
        return HttpResult.ok(resultMap);
    }
}
